{view 'public/head'}
</head>
<body>
    <div class="container-fluid">
        <p><a href="{site 'system/meun_add'}" title="新增菜单" class="btn"><i class="icon-plus"></i> 新增菜单</a></p>
        <ul class="nav nav-tabs">
            {loop $list as $key=>$var}
            <li menuid="{$var.id}"{$_COOKIE.systemmeunnavtabs===$var.controller||(empty($_COOKIE.systemmeunnavtabs)&&$key=='0')?' class="active"':''} onclick="$.cookie('systemmeunnavtabs', '{$var.controller}');"><a href="#{$var.controller}" data-toggle="tab">{$var.name}</a></li>
            {/loop}
        </ul>
        <div class="tab-content">
            {loop $list as $key=>$var}
            <div class="tab-pane fade in{$_COOKIE.systemmeunnavtabs===$var.controller||(empty($_COOKIE.systemmeunnavtabs)&&$key=='0')?' active':''}" id="{$var.controller}">
                <table class="table table-hover">
                    <thead>
                        <tr>
                            <th>菜单标题</th>
                            <th>GROUP</th>
                            <th>CONTROLLER</th>
                            <th>ACTION</th>
                            <th>备注</th>
                            <th style="width:50px">显示</th>
                            <th style="width:60px">可关闭</th>
                            <th style="width:50px;text-align:center">新增</th>
                            <th style="width:50px;text-align:center">修改</th>
                            <th style="width:50px;text-align:center">删除</th>
                            <th style="width:50px;text-align:center">排序</th>
                        </tr>
                    </thead>
                    <tr menuid="{$var.id}">
                        <td colspan="2">{$var.name}</td>
                        <td colspan="2">{$var.controller}</td>
                        <td></td>
                        <td>{$var.status?'<i class="icon-ok"></i>':''}</td>
                        <td></td>
                        <td><a href="{site 'system/meun_add/'.$var.id}" title="新增菜单"><i class="icon-plus"></i> 新增</a></td>
                        <td style="text-align:center"><a href="{site 'system/menu_edit/'.$var.id}"><i class="icon-edit"></i> 修改</a></td>
                        <td style="text-align:center"><a data-trigger="confirm" data-content="你确定要删除吗？删除后无法恢复" href="{site 'system/menu_delete/'.$var.id}"><i class="icon-remove"></i> 删除</a></td>
                        <td style="text-align:center" onmouseover="onmouseoverdragsort()" onmouseout="onmouseoutdragsort()"><i class="icon-move"></i> 排序</td>
                    </tr>
                    {loop $var.s as $var2}
                    <tr menuid="{$var2.id}">
                        <td></td>
                        <td colspan="3">{$var2.name}</td>
                        <td></td>
                        <td>{$var2.status?'<i class="icon-ok"></i>':''}</td>
                        <td></td>
                        <td><a href="{site 'system/meun_add/'.$var2.m_id.'/'.$var2.id}" title="新增菜单"><i class="icon-plus"></i> 新增</a></td>
                        <td style="text-align:center"><a href="{site 'system/menu_edit/'.$var2.id}"><i class="icon-edit"></i> 修改</a></td>
                        <td style="text-align:center"><a data-trigger="confirm" data-content="你确定要删除吗？删除后无法恢复" href="{site 'system/menu_delete/'.$var2.id}"><i class="icon-remove"></i> 删除</a></td>
                        <td style="text-align:center" onmouseover="onmouseoverdragsort()" onmouseout="onmouseoutdragsort()"><i class="icon-move"></i> 排序</td>
                    </tr>
                    {loop $var2.s as $var3}
                    <tr menuid="{$var3.id}">
                        <td>{$var3.name}</td>
                        <td colspan="2"></td>
                        <td>{$var3.action}</td>
                        <td>{$var3.remark}</td>
                        <td>{$var3.status?'<i class="icon-ok"></i>':''}</td>
                        <td>{$var3.closeable?'<i class="icon-ok"></i>':''}</td>
                        <td></td>
                        <td style="text-align:center"><a href="{site 'system/menu_edit/'.$var3.id}"><i class="icon-edit"></i> 修改</a></td>
                        <td style="text-align:center"><a data-trigger="confirm" data-content="你确定要删除吗？删除后无法恢复" href="{site 'system/menu_delete/'.$var3.id}"><i class="icon-remove"></i> 删除</a></td>
                        <td style="text-align:center" onmouseover="onmouseoverdragsort()" onmouseout="onmouseoutdragsort()"><i class="icon-move"></i> 排序</td>
                    </tr>
                    {/loop}
                    {/loop}

                </table>
            </div>
            {/loop}
        </div>
    </div>
    {view 'public/js'}
    <script type="text/javascript">
        $(document).ready(function () {
            onmouseoutdragsort();
            $("ul").dragsort("destroy");
            $("ul").dragsort({dragSelector: "li", dragBetween: true, dragEnd: saveOrder2});
        });
        function saveOrder2() {
            var data = $("ul li").map(function () {
                return $(this).attr('menuid');
            }).get();
            ajax_post("{site 'system/menu_sort'}", 'sort=' + data.join("|"));
        }
        function saveOrder() {
            var data = $("table tbody tr").map(function () {
                return $(this).attr('menuid');
            }).get();
            ajax_post("{site 'system/menu_sort'}", 'sort=' + data.join("|"));
        }
        function onmouseoutdragsort() {
            $("table tbody").dragsort("destroy");
        }
        function onmouseoverdragsort() {
            $("table tbody").dragsort({dragSelector: "tr", dragBetween: true, dragEnd: saveOrder});
        }
    </script>   
</body>
</html>